package blow.sky.quoted.controller;

import blow.sky.quoted.dao.UserInfoDao;
import blow.sky.quoted.entity.UserInfo;
import blow.sky.quoted.response.MsgResponse;
import blow.sky.quoted.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName InfoController
 * @Description TODO
 * @Author 江志武
 * @Date 2021/6/3 11:33
 */
@RestController
@RequestMapping("/api/info")
public class InfoController {
    @Autowired
    UserInfoService service;
    @PostMapping("/updateOne")
    public MsgResponse update(@RequestBody UserInfo userInfo)
    {
        try{
            service.getInfo(userInfo);
            return new MsgResponse("success");
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return new MsgResponse("fail","Format Error");
        }
    }

    @GetMapping("/GetEmail/{UserEmail}")
    public UserInfo info(@PathVariable("UserEmail") String email)
    {
        return service.info(email);
    }

    @GetMapping("/GetAll")
    public List<UserInfo> Allinfo()
    {
        return service.getAll();
    }
}
